<?php

//print_r($_POST);
 
// username and password sent from form 


print_r($_POST);
//return;
$uid=$_POST['uid'];

if($_POST['option']=='scan_code'){
	
    $scan_code=$_POST['scan_code'];
	
}elseif($_POST['option']=='product_code'){
	    $product_code=$_POST['product_code'];
		$color=$_POST['color'];
		$size=$_POST['size'];
		$scan_code=$product_code.$color.$size;

}elseif($_POST['option']=='all_code'){
		$type=$_POST['type'];
		$year=$_POST['year'];
		$season=$_POST['season'];
		$flow=$_POST['flow'];
		$material=$_POST['material'];
		$color=$_POST['color'];
		$size=$_POST['size'];
        $scan_code=$type.$year.$season.$flow.$material.$color.$size;
	

}else{
	echo "option error";  return;
}
$designer=$_POST['designer'];
$name=$_POST['name'];
$active=$_POST['active'];
$price=$_POST['price'];
$ratio=$_POST['ratio'];

    if(isItemExist($scan_code)){
    	
    	header("location:../index.php?page=manage_items&stat=error&error=duplicated");
    }else{
    	//...do add new item
    	if(createItem($scan_code,$designer,$name,$active,$price,$ratio)){
    	header("location:../index.php?page=manage_items&stat=inserted");
			
    	}else{
    	header("location:../index.php?page=manage_items&stat=error&error=badData");
			
    	}
    
    	//header("location:../index.php?page=stack&id=".$Orid."&error=checkfail");
		
    }

  return ;

?>